<?php
/**
 * SocialEngine
 *
 * @category   Application_Core
 * @package    User
 * @copyright  Copyright 2006-2010 Webligo Developments
 * @license    http://www.socialengine.net/license/
 * @version    $Id: Filter.php 9076 2011-07-21 02:11:10Z john $
 * @author     John
 */

/**
 * @category   Application_Core
 * @package    User
 * @copyright  Copyright 2006-2010 Webligo Developments
 * @license    http://www.socialengine.net/license/
 */
class User_Form_Admin_Manage_Filter extends Engine_Form {
	public function init() {
		$this->clearDecorators ()->addDecorator ( 'FormElements' )->addDecorator ( 'Form' )->addDecorator ( 'HtmlTag', array ('tag' => 'div', 'class' => 'search' ) )->addDecorator ( 'HtmlTag2', array ('tag' => 'div', 'class' => 'clear' ) );
		
		$this->setAttribs ( array ('id' => 'filter_form', 'class' => 'global_form_box' ) );
		
		$displayname = new Zend_Form_Element_Text ( 'displayname' );
		$displayname->setLabel ( 'Display Name' )->clearDecorators ()->addDecorator ( 'ViewHelper' )->addDecorator ( 'Label', array ('tag' => null, 'placement' => 'PREPEND' ) )->addDecorator ( 'HtmlTag', array ('tag' => 'div' ) );
		
		$username = new Zend_Form_Element_Text ( 'username' );
		$username->setLabel ( 'Username' )->clearDecorators ()->addDecorator ( 'ViewHelper' )->addDecorator ( 'Label', array ('tag' => null, 'placement' => 'PREPEND' ) )->addDecorator ( 'HtmlTag', array ('tag' => 'div' ) );
		
		$email = new Zend_Form_Element_Text ( 'email' );
		$email->setLabel ( 'Email' )->clearDecorators ()->addDecorator ( 'ViewHelper' )->addDecorator ( 'Label', array ('tag' => null, 'placement' => 'PREPEND' ) )->addDecorator ( 'HtmlTag', array ('tag' => 'div' ) );
		
		$levels = Engine_Api::_ ()->getDbtable ( 'levels', 'authorization' )->getLevelsAssoc ();
		$levelMultiOptions = array_merge ( array (0 => ' ' ), $levels );
		
		$level_id = new Zend_Form_Element_Select ( 'level_id' );
		$level_id->setLabel ( 'Level' )->clearDecorators ()->addDecorator ( 'ViewHelper' )->addDecorator ( 'Label', array ('tag' => null, 'placement' => 'PREPEND' ) )->addDecorator ( 'HtmlTag', array ('tag' => 'div' ) )->setMultiOptions ( $levelMultiOptions );
		
		$enabled = new Zend_Form_Element_Select ( 'enabled' );
		$enabled->setLabel ( 'Approved' )->clearDecorators ()->addDecorator ( 'ViewHelper' )->addDecorator ( 'Label', array ('tag' => null, 'placement' => 'PREPEND' ) )->addDecorator ( 'HtmlTag', array ('tag' => 'div' ) )->setMultiOptions ( array ('-1' => '', '0' => 'Not Approved', '1' => 'Approved' ) )->setValue ( '-1' );
		
		$submit = new Zend_Form_Element_Button ( 'search', array ('type' => 'submit' ) );
		$submit->setLabel ( 'Search' )->clearDecorators ()->addDecorator ( 'ViewHelper' )->addDecorator ( 'HtmlTag', array ('tag' => 'div', 'class' => 'buttons' ) )->addDecorator ( 'HtmlTag2', array ('tag' => 'div' ) );
		
		$this->addElement ( 'Hidden', 'order', array ('order' => 10001 ) );
		
		$this->addElement ( 'Hidden', 'order_direction', array ('order' => 10002 ) );
		
		$this->addElements ( array ($displayname, $username, $email, $level_id, $enabled, $submit ) );
		
		// Set default action without URL-specified params
		$params = array ();
		foreach ( array_keys ( $this->getValues () ) as $key ) {
			$params [$key] = null;
		}
		$this->setAction ( Zend_Controller_Front::getInstance ()->getRouter ()->assemble ( $params ) );
	}
}